<?php
class Admin_Form_Search_Tour extends Apps_Plugin_Grid_Search_Abstract {
    public function preInit() {
        $dMapper 			= new M_Tool_DataMapper();
        $tourCategoryList 	= $dMapper->mapKeyValue(new M_DbTable_TourCategory(), 'id', 'en_title');
        $countryList 	= $dMapper->mapKeyValue(new M_DbTable_Country(), 'id', 'en_name');
        $tourStyleList 		= $dMapper->mapKeyValue(new M_DbTable_TourStyle(), 'id', 'en_title');

        $advancedCriteria = array(
            'en_title' => array(
                    'a.en_title',
                    self::$criteriaStringLike,
                    array(
                            'element'  => self::ELEMENT_TEXT,
                            'label'    => 'Title (EN)',
                    )
            ),
            'title' => array(
                    'a.title',
                    self::$criteriaStringLike,
                    array(
                            'element'  => self::ELEMENT_TEXT,
                            'label'    => 'Title (VI)',
                    )
            ),
            'category' => array(
            		't.tour_category_id',
            		self::$criteriaSimple,
					array(
							'element'	   => self::ELEMENT_SELECT,
							'label'		   => 'Category',
							'multiOptions' => $tourCategoryList
					)
            ),
            'style' => array(
            		't.tour_style_id',
            		self::$criteriaSimple,
					array(
							'element'	   => self::ELEMENT_SELECT,
							'label'		   => 'Trip in style',
							'multiOptions' => $tourStyleList
					)
            ),
            'country' => array(
            		't.country_id',
            		self::$criteriaSimple,
					array(
							'element'	   => self::ELEMENT_SELECT,
							'label'		   => 'Country',
							'multiOptions' => $countryList
					)
            )
        );

        $simpleCriteria = array(
        		array('t.id LIKE ?', '%%%s%%'),
        		array('a.en_title LIKE ?', '%%%s%%'),
        		array('a.title LIKE ?', '%%%s%%'),
        		array('t_c.en_title LIKE ?', '%%%s%%'),
        		array('t_s.en_title LIKE ?', '%%%s%%'),
        		array('c.en_name LIKE ?', '%%%s%%'),
        );

        $this->setAdvCriteria($advancedCriteria);
        $this->setSplCriteria($simpleCriteria);
    }
}